<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <style>
        html,
        body,
        #mapui {
            width: 100%;
            height: 100%;
        }

        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="mapui"></div>

    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>
    <script>
        var amap = null;
        var that = this;
        var frameCount = 5;
        var currentImage = 0;
        map.Factory.create('mapui', {
            center: [-75.789, 41.874],
            fullExtent: {
                xmin: 90.992204,
                ymin: 10.979711,
                xmax: 120.5338915,
                ymax: 50.543712
            },
            zoom: 5,
            projection: 'EPSG:4326',
           strategy: ['mapboxgl', 'openlayers'],
            style: style
        }, (o) => {
            amap = o;
            that.init(amap.pmap);
        });


        function init(map) {
            map.addSource("radar", {
                type: "image",
                url: getPath(),
                coordinates: [
                    [-80.425, 46.437],
                    [-71.516, 46.437],
                    [-71.516, 37.936],
                    [-80.425, 37.936]
                ]
            });
            map.addLayer({
                id: "radar-layer",
                "type": "raster",
                "source": "radar",
                "paint": {
                    "raster-fade-duration": 0
                }
            });

            setInterval(function () {
                currentImage = (currentImage + 1) % frameCount;
                map.getSource("radar").updateImage({ url: getPath() });
            }, 200);
        }

        function getPath() {
            return "https://docs.mapbox.com/mapbox-gl-js/assets/radar" + currentImage + ".gif";
        }
    </script>
</body>

</html>